@include('admin.layout.bone_header')

<div class="layui-btn-container">
    <button class="layui-btn" data-type="addImages">添加任务</button>
</div>



<table class="layui-hide" id="think-table" lay-filter="think-table"></table>

<script type="text/html" id="barDemo">

    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>



</script>

<script>

    layui.use('table', function () {
        let table = layui.table;
        UI.getPageTable(table, "{{route('admin.task.lists')}}", [
            {field: 'task_id', title: 'ID', width: 80, sort: true, fixed: 'left'}
            , {field: 'task_title', title: '任务名称'}
            , {field: 'task_num', title: '任务奖励'}

            ,{fixed: 'right',title:'操作', align:'center', toolbar: '#barDemo'}
        ]);

        table.on('tool(think-table)', function (obj) {
            let data = obj.data;
            if(obj.event === 'edit'){
                UI.openLayer("{{route('admin.task.edit')}}?task_id="+data['task_id']);
            }
        });
        let $ = layui.$, active = {
            addImages:function (){
                UI.openLayer("{{route('admin.task.add')}}");
            }
        };
        $('.layui-btn-container .layui-btn').on('click', function () {
            let type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

        $('.search .layui-btn').on('click', function () {
            let type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

    })


</script>


@include('admin.layout.bone_footer')
